package com.dmgis.qxfw.dataservice.businessservice.common.util;

import org.dom4j.Document;
import org.dom4j.Node;

/**
 * 微信订阅消息
 *
 * @author dsq
 * @date 2019年12月3日
 */
public class EventMessage extends WeChatMessage {
    /**
     * 事件类型
     */
    private String event;
    /**
     * 事件KEY值，是一个32位无符号整数，即创建二维码时的二维码scene_id
     */
    private String eventKey;
    /**
     * 二维码的ticket，可用来换取二维码图片
     */
    private String ticket;
    /**
     * 地理位置纬度
     */
    private String latitude;
    /**
     * 地理位置经度
     */
    private String longitude;
    /**
     * 地理位置精度
     */
    private String precision;

    public String getEvent() {
        return event;
    }

    public void setEvent(String event) {
        this.event = event;
    }

    public EventMessage() {
    }

    public String getEventKey() {
        return eventKey;
    }

    public void setEventKey(String eventKey) {
        this.eventKey = eventKey;
    }

    public String getTicket() {
        return ticket;
    }

    public void setTicket(String ticket) {
        this.ticket = ticket;
    }

    public String getLatitude() {
        return latitude;
    }

    public void setLatitude(String latitude) {
        this.latitude = latitude;
    }

    public String getLongitude() {
        return longitude;
    }

    public void setLongitude(String longitude) {
        this.longitude = longitude;
    }

    public String getPrecision() {
        return precision;
    }

    public void setPrecision(String precision) {
        this.precision = precision;
    }

    public EventMessage(Document xmlDoc) {
        super(xmlDoc);
        Node event = xmlDoc.selectSingleNode("/xml/Event");
        Node eventKey = xmlDoc.selectSingleNode("/xml/EventKey");
        Node ticket = xmlDoc.selectSingleNode("/xml/Ticket");
        Node latitude = xmlDoc.selectSingleNode("/xml/Latitude");
        Node longitude = xmlDoc.selectSingleNode("/xml/Longitude");
        Node precision = xmlDoc.selectSingleNode("/xml/Precision");
        if (event != null)
            this.setEvent(event.getText());
        if (eventKey != null)
            this.setEventKey(eventKey.getText());
        if (ticket != null)
            this.setTicket(ticket.getText());
        if (latitude != null)
            this.setLatitude(latitude.getText());
        if (longitude != null)
            this.setLongitude(longitude.getText());
        if (precision != null)
            this.setPrecision(precision.getText());
    }
}
